import{LOGIN_ERROR,LOGIN_SUCCESS} from "../action-types"


const actionCreators ={
    login(user){
        return function(dispatch,getState,request){
            console.log(user,'Longin22');
            return  request.post('/api/login',user).then(res=>{
                
                const {success,data,error} = res.data
                localStorage.setItem('token',token)
                if(success){
                    dispatch({
                        type:LOGIN_SUCCESS,
                        payload:res.data
                    })
                }else{
                    dispatch({
                        type:LOGIN_ERROR,
                        payload:error
                    })
                }
                
            })
        }
    }

}


export default actionCreators